import React from 'react';
// import { connect } from 'react-redux'
import { Card, Space, Button, Checkbox, Form, Input } from 'antd';
import LoginStyle from './LoginStyle.less';
import './LoginStyle.less'
import {addCanvas} from '@/hoc/index.js'
import { userLogin } from '@/api/login';
import { withRouter } from 'umi';
import {debounce} from '@/utils/fdjl'



export const index = (props: any) => {
  console.log(props);
  
  const {history} =props

  const onFinish = debounce(1000,(values: any)=>{
    console.log('Success:', values);
    // userLogin(values).then(res=>{
    //   console.log(res);
    // })
    sessionStorage.setItem('token','dhgnczuedhhjd')
    history.push('/index/houses/houselist')
  });

  const onFinishFailed = (errorInfo: any) => {
    console.log('Failed:', errorInfo);
  };

  return (
    <div className={LoginStyle.login}>
      <Card
        title="管理中心登录"
        // extra={<div></div>}
        headStyle={{fontWeight:700,fontSize:'22px'}}
        style={{ width: 300,textAlign:'center',borderRadius:'10px'}}
        className={LoginStyle.card}
      >
        <Form
          name="basic"
          wrapperCol={{ span: 24 }}
          initialValues={{ remember: true }}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            name="username"
            rules={[{ required: true, message: '请输入账号' }]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            name="password"
            rules={[{ required: true, message: '请输入密码' }]}
          >
            <Input.Password />
          </Form.Item>

          <Form.Item
            name="yzm"
            rules={[{ required: true, message: '请输入验证码' }]}
          >
            <Space>
              <Input />
              <img src="http://fangadmin.shbwyz.com/login/verfiy.html" alt="" />
            </Space>
            
          </Form.Item>

          <Form.Item wrapperCol={{  span: 24 }}>
            <Button type="primary" htmlType="submit">
              登录
            </Button>
          </Form.Item>
        </Form>
      </Card>
    </div>
  );
};

// const mapStateToProps = (state:any) => ({})

// const mapDispatchToProps = {}

export default addCanvas(withRouter(index));
